package com.cloudbroker.bcs.platform.dav.middle.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        File file = new File("src/main/resources/message/error-desc_zh_CN.properties");
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(file));
            String tempString;
            while ((tempString = br.readLine()) != null) {
                String[] s = tempString.split("=");
                if (s == null || s.length < 2) {
                    continue;
                }
                System.out.println(s[0] + "=" + unicode2String(s[1]));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    /**
     * unicode 转字符串
     */
    public static String unicode2String(String unicode) {
        
        StringBuffer string = new StringBuffer();
        
        String[] hex = unicode.split("\\\\u");
        
        for (int i = 1; i < hex.length; i++) {
            
            // 转换出每一个代码点
            int data = Integer.parseInt(hex[i], 16);
            
            // 追加成string
            string.append((char) data);
        }
        
        return string.toString();
    }
    
}
